var cardAmt = wx.createAnimation({
  duration:1500,
  timingFunction:'linear'
});
var timeid,amtStatus;
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        var imghgt = 363 * res.windowWidth / 750;
        that.setData({
          top_img_hgt: imghgt
        });
      },
    });
    amtStatus = 0;
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.startAnimation();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    this.stopAnimation();
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    this.stopAnimation();
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  ucAction: function (event) {
    var actiontype = event.currentTarget.dataset.actiontype;
    if(actiontype == 'order'){
      wx.navigateTo({
        url: './order/order',
      });
    }
    else if(actiontype == 'address'){
      wx.navigateTo({
        url: './address/address',
      });
    }
    else if(actiontype == 'person'){
      wx.navigateTo({
        url: './editinfo/editinfo',
      });
    }
    else if (actiontype == 'vip'){
      wx.navigateTo({
        url: './vip/vip',
      });
    }
    else if (actiontype == 'card'){
      wx.navigateTo({
        url: './card/card',
      });
    }
    else if (actiontype == 'shop'){
      wx.navigateTo({
        url: './stores/stores?target=store',
      });
    }
  },
  maidianDetail:function(){
    wx.navigateTo({
      url: './mddetail/mddetail',
    });
  },
  contactClient:function(){
    wx.makePhoneCall({
      phoneNumber: '400-992-6632',
    });
  },
  suggestReturn:function(){
    wx.navigateTo({
      url: './suggest/suggest',
    });
  },
  memoryDays:function(){
    wx.navigateTo({
      url: './days/days',
    })
  },
  balanceDeal:function(){
    wx.navigateTo({
      url: './balance/balance',
    });
  },
  couponDetail:function(){
    wx.navigateTo({
      url: './coupon/couponindex',
    });
  },
  normalQA:function(){
    wx.navigateTo({
      url: './stores/stores?target=qa',
    });
  },
  freePay:function(){
    wx.navigateTo({
      url: './freepay/freepay',
    });
  },
  //-----------------------------------------------------AMT----------------
  startAnimation:function(){
    // console.log('amt');
    var that = this;
    timeid = setTimeout(function(){
      if(timeid){
        clearTimeout(timeid);
        amtStatus = amtStatus == 0 ? 1 : 0;
        that.animationCreate(amtStatus);
      }
    },1600);
  },
  stopAnimation:function(){
    if(timeid){
      clearTimeout(timeid);
    }
  },
  animationCreate:function(status){
    var tarval = -35;
    if(status == 1){
      tarval = -20;
    }
    cardAmt.bottom(tarval).step();
    this.setData({
      cardAnimation:cardAmt.export()
    });
    this.startAnimation();
  }
})